import axiosIns from '@/plugins/axios';

// 获取已批准的初访预约列表
export async function getApprovedInitialAppointments() {
  const options = {
    method: 'GET',
    url: `/api/appointment/approved-initial`,
    headers: {
      'Content-Type': 'application/json'
    }
  };
  return axiosIns.request(options);
}

// 获取初访记录列表
export async function getInitialVisitRecords() {
  const options = {
    method: 'GET',
    url: `/api/visit-record/initial`,
    headers: {
      'Content-Type': 'application/json'
    }
  };
  return axiosIns.request(options);
}

// 创建初访记录
export async function createVisitRecord(visitRecordData: {
  appointment_id: number;
  visitor_id: number;
  type: string;
  visit_time: string;
  risk_level: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
  problem_type: string;
  conclusion: string;
  note: string;
}) {
  const options = {
    method: 'POST',
    url: `/api/visit-record/create`,
    data: visitRecordData,
    headers: {
      'Content-Type': 'application/json'
    }
  };
  return axiosIns.request(options);
}

// 更新预约状态为已完成
export async function updateAppointmentStatus(appointmentId: number, status: string) {
  const options = {
    method: 'POST',
    url: `/api/appointment/update-status`,
    data: {
      id: appointmentId,
      status: status
    },
    headers: {
      'Content-Type': 'application/json'
    }
  };
  return axiosIns.request(options);
} 